home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
kermit.columbia.edu
/
kermit.columbia.edu.tar
/
kermit.columbia.edu
/
newsgroups
/
misc.19981211-19990422
/
000265_news@watsun.cc.columbia.edu _Mon Feb 22 18:58:46 1999.msg
< prev
next >
Wrap
Internet Message Format
|
1999-04-21
|
4KB
Return-Path: <news@watsun.cc.columbia.edu>
Received: from newsmaster.cc.columbia.edu (newsmaster.cc.columbia.edu [128.59.59.30])
by watsun.cc.columbia.edu (8.8.5/8.8.5) with ESMTP id SAA28375
for <kermit.misc@watsun.cc.columbia.edu>; Mon, 22 Feb 1999 18:58:45 -0500 (EST)
Received: (from news@localhost)
by newsmaster.cc.columbia.edu (8.8.5/8.8.5) id SAA23264
for kermit.misc@watsun.cc.columbia.edu; Mon, 22 Feb 1999 18:38:26 -0500 (EST)
X-Authentication-Warning: newsmaster.cc.columbia.edu: news set sender to <news> using -f
From: fdc@watsun.cc.columbia.edu (Frank da Cruz)
Subject: Re: Don't want to send file if filesize grows
Date: 22 Feb 1999 23:38:19 GMT
Organization: Columbia University
Message-ID: <7asppb$mmr$1@newsmaster.cc.columbia.edu>
To: kermit.misc@mailrelay2.cc.columbia.edu
In article <19990222180043.02874.00001668@ng-fx1.aol.com>,
OhOhTrubba <ohohtrubba@aol.com> wrote:
: I have a directory called testdirectory. It has files constantly coming
: into it 24 hours a day. I need to have a script send these files to
: another directory on another filesystem; however, I have to make sure the
: file is complete first otherwise I'll send over partial data. I'm
: visualizing in my head something involving ls'ing the directory and
: looking at the filesize bytes. Then five minutes later, looking at the
: filesize again and if the filesize does NOT grow, send the file. If it
: does grow, leave the file where it's at and check it again in another five
: minutes. However, I'm new to Unix and don't even know where to begin. I
: know ls could look at the files, awk could grab the filesize bytes and
: cron could make something happen every five minutes, but other than that,
: I'm clueless. HELP, please.
:
You didn't say how you are transferring the files, but tasks like these are
easily accomplished (and automated) using C-Kermit scripts. The easiest
approach is to send a file to Directory A, and then move it to Directory B
after it is completely transferred. Or rename it to a name that indicates
it has been fully transferred. For example, let's say a Kermit server is
running on your AIX host, and its current directory is "tmp", which is
parallel with "testdir". The client does:
send blah ; ("blah" is the filename)
if success remote rename blah ../testdir/blah
This ensures that the file is moved to testdir if and only if it was
transferred fully and successfully.
Meanwhile your other process on the same AIX system is looking for files to
appear in testdir. Let's say "testdir" is its current directory. It can do
something like this:
while true {
assign \%n \ffiles(*,&f) ; Look for any files (1)
xif > \%n 0 { ; There are some
for \%i 1 \%n 1 { ; Loop through the list
move \&f[\%i] ; Send each file (2)
}
} else { ; No files to send
sleep 10 ; Sleep 10 seconds
}
}
Notes:
(1) \ffiles(*,&f) assigns the list of all files whose names match the
pattern ("*" in this case) to the array \&f[]. C-Kermit 7.0 (currently
in Beta test) is required to use this feature; somewhat less convenient
methods are available in earlier versions.
(2) The "move" command means "send the file and then, if and only if the
transfer was successful, delete it". This ensures the same file won't
be sent twice. Note that we don't care about failure here; if a file
is not transferred successfully, we'll catch it again next time through
the loop.
More info about C-Kermit at:
http://www.columbia.edu/kermit/ckermit.html
And about C-Kermit 7.0 at:
http://www.columbia.edu/kermit/ck70.html
- Frank